<script>
import { requestData } from './utils/http'
export default {
  globalData: {
    text: '全局数据',
   // user_id: '',
  },
  onLaunch: function () {
    // 打开调试
    uni.setEnableDebug({
      enableDebug: true,
    })
  },
  onShow: function () {
    let user_id = uni.getStorageSync('user_id')
    if (!user_id) {
      uni.login({
        success: (res) => {
          requestData('/wxaccess/mp/user/login', {
            wxlogin_code: res.code,
          })
            .then((res) => {
              uni.removeStorageSync('open_id')
              uni.removeStorageSync('access_token')
              uni.removeStorageSync('user_id')
              uni.removeStorageSync('mobile')
              uni.setStorageSync('open_id', res?.data?.datas?.open_id || '')
              uni.setStorageSync('user_id', res?.data?.datas?.user_id || '')
              uni.setStorageSync('mobile', res?.data?.datas.mobile || '')
              uni.setStorageSync(
                'access_token',
                res?.data?.datas?.access_token || ''
              )
            })
            .catch((err) => {
              console.log(err)
            })
        },
        fail: (err) => {
          console.log(err)
        },
      })
    }
  },

  onHide: function () {},
}
</script>
<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import '@/uni_modules/uview-ui/index.scss';

page {
  font-size: 32rpx !important;
}

uni-toast .uni-toast__content {
  font-size: 28rpx;
  white-space: pre-wrap;
}
</style>
.
